package test12;

import java.util.InputMismatchException;

public class SumNum {
    public double getNum1() {
        return num1;
    }

    public void setNum1(double num1) {
        try {
            this.num1 = num1;
        }catch (InputMismatchException e){
            System.out.println("非法数据，请输入正确的数字");
        }

    }

    public double getNum2() {
        return num2;
    }

    public void setNum2(double num2) {
        try {
            this.num2 = num2;
        }catch (InputMismatchException e){
            System.out.println("非法数据，请输入正确的数字");
        }
    }

    public void getSum(){
        double temp = num1+num2;
        System.out.println("两数之和为："+temp);
    }

    //可求两个数字的和
    private double num1;
    private double num2;


}
